//--------------------------------------------------------------------
//
//    Copyright (C) Streamlet. All rights reserved.
//
//    File Name:   IME.h
//    Author:      Streamlet
//    Create Time: 2015-01-06
//    Description: 
//
//    Version history:
//
//
//--------------------------------------------------------------------

#ifndef __IME_H_7279801A_2021_413A_9352_8FC144363DC9_INCLUDED__
#define __IME_H_7279801A_2021_413A_9352_8FC144363DC9_INCLUDED__


#include "xlUSKeyboard_h.h"
#include <xl/Win32/COM/xlComInclude.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfTextInputProcessorExImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfThreadMgrEventSinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfTextEditSinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfKeyEventSinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfCompositionSinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfDisplayAttributeProviderImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfActiveLanguageProfileNotifySinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfThreadFocusSinkImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfFunctionProviderImpl.h>
#include <xl/Win32/COM/InterfaceHelper/xlITfFnGetPreferredTouchKeyboardLayoutImpl.h>

class IME : public xl::ComClass<IME>,
            public xl::Dispatcher<>,
            public xl::ITfTextInputProcessorExImpl<>,
            public xl::ITfThreadMgrEventSinkImpl<>,
            public xl::ITfTextEditSinkImpl<>,
            public xl::ITfKeyEventSinkImpl<>,
            public xl::ITfCompositionSinkImpl<>,
            public xl::ITfDisplayAttributeProviderImpl<>,
            public xl::ITfActiveLanguageProfileNotifySinkImpl<>,
            public xl::ITfThreadFocusSinkImpl<>,
            public xl::ITfFunctionProviderImpl<>,
            public xl::ITfFnGetPreferredTouchKeyboardLayoutImpl<>
{
public:
    IME();
    ~IME();

public:
    XL_COM_INTERFACE_BEGIN(IME)
        XL_COM_INTERFACE(ITfTextInputProcessorEx)
        XL_COM_INTERFACE(ITfThreadMgrEventSink)
        XL_COM_INTERFACE(ITfTextEditSink)
        XL_COM_INTERFACE(ITfKeyEventSink)
        XL_COM_INTERFACE(ITfCompositionSink)
        XL_COM_INTERFACE(ITfDisplayAttributeProvider)
        XL_COM_INTERFACE(ITfActiveLanguageProfileNotifySink)
        XL_COM_INTERFACE(ITfThreadFocusSink)
        XL_COM_INTERFACE(ITfFunctionProvider)
        XL_COM_INTERFACE(ITfFnGetPreferredTouchKeyboardLayout)
    XL_COM_INTERFACE_END()

public:
    // ITfTextInputProcessor
    STDMETHOD(Activate)(ITfThreadMgr *ptim, TfClientId tid);
    STDMETHOD(Deactivate)();

    // ITfTextInputProcessorEx
    STDMETHOD(ActivateEx)(ITfThreadMgr *ptim, TfClientId tid, DWORD dwFlags);

    // ITfActiveLanguageProfileNotifySink
    STDMETHOD(OnActivated)(_In_ REFCLSID clsid, _In_ REFGUID guidProfile, _In_ BOOL isActivated);

private:
    bool AddTextProcessorEngine();
};

XL_DECLARE_COM_CLASS(IME,
                     _T("xlUSKeyboard IME Class"),
                     _T("xlUSKeyboard.IME"),
                     _T("1"));


#endif // #ifndef __IME_H_7279801A_2021_413A_9352_8FC144363DC9_INCLUDED__
